package models

import (
	"gin-easy/pkg/zap_log"
	"gorm.io/gorm"
)

type Article struct {
	gorm.Model
	Title   string
	Content string
}

// 插入新文章
func ArticleCreate(data map[string]interface{}) bool {
	a := Article{
		Title:   data["title"].(string),
		Content: data["content"].(string),
	}
	res := db.Create(&a)
	if res.Error != nil {
		zap_log.Lg.Fatal("保存失败")
		return false
	}
	return true
}
